<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="../static/js/jquery-1.8.2.min.js"></script>
    <link rel="stylesheet" href="../static/css/css1.css">
</head>
<body>
<div class="container">
    <div class="col-md-9"></div>
    <h2 class="col-md-3" style="color: blue">用户登录</h2>
    <form class="form-horizontal"  role="form">
        <div class="form-group">
            <div class="col-sm-6"></div>
            <label class="col-sm-2 control-label">用户名</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="userName" placeholder="请输入用户名">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-6"></div>
            <label class="col-sm-2 control-label">密码</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="password" placeholder="请输入密码">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-9 col-sm-5">
                <button type="button" id="go" class="btn btn-default">登录</button>&emsp;
                <button type="button" onclick="goRegis()" class="btn btn-default">注册</button>
            </div>
        </div>

    </form>
</div>
</body>
<script>
    function goRegis(){
        location = "/user/goRegis";
    }
    $("#go").click(function () {
        $.post(
            "/user/login",
            $("form").serialize(),
            function (a){
                if (a==1){
                    alert("登陆成功");
                    location = "/order/orderList";
                }else if (a==2){
                    alert("密码错误");
                }else {
                    alert("用户名错误");
                }
            }
        )
    })
</script>
</html>
